using JT808Protocol.Common;
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace JT808Protocol.Models.BodyParserStrategy
{
    /// <summary>
    /// 电子运单上报
    /// </summary>
    public class DrOrderReport_0x0701 : IJT808Body
    {
        /// <summary>
        /// 电子运单长度
        /// </summary>
        [JsonPropertyName("电子运单长度")] public uint OrderLength { get; set; }

        /// <summary>
        /// 电子运单数据
        /// </summary>
        [JsonPropertyName("电子运单数据")] public byte[] OrderData { get; set; }

        public override IJT808Body ReadBody(ReadOnlySpan<byte> source, ref int startIndex)
        {
            //电子运单长度
            OrderLength = ParseHelper.Uint32(ref source, startIndex);

            //电子运单内容
            startIndex += 4;
            OrderData = new byte[OrderLength];
            Array.Copy(source.ToArray(), startIndex, OrderData, 0, OrderLength);

            return this;
        }

        public override List<byte> WriteToBytes()
        {
            throw new NotImplementedException();
        }
    }
}